package com.sam.nosql;

import android.app.Application;
import android.test.ApplicationTestCase;

import com.sam.data.UserDataForRealm;

import io.realm.Realm;
import io.realm.RealmConfiguration;

/**
 * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
 */
public class RealmTest extends ApplicationTestCase<Application> {
    private Realm mRealm;
    public RealmTest() {
        super(Application.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        Realm.setDefaultConfiguration(new RealmConfiguration.Builder(mContext).build());
        mRealm = Realm.getDefaultInstance();
        mRealm = Realm.getInstance(mContext);

    }

    public void testObj(){
//        Realm.createObject(), it will return a new object with all fields set to the default
        UserDataForRealm data = new UserDataForRealm();
        data.setName("testObj");
        data.setAge(1);
        data.setHeight(1.1f);
        mRealm.beginTransaction();
//        mRealm.copyToRealm(data);
        mRealm.copyToRealmOrUpdate(data);
        mRealm.commitTransaction();
    }
    public void testList(){


    }
}